package my.jbf.firstGame.BITMAP;
import android.graphics.*;
import my.jbf.firstGame.*;
import my.jbf.firstGame.Game.FightData;
import my.jbf.firstGame.Game.PlayerData;

public class FightMap
{
	private String name;
	private String _ID;
	private Bitmap mBitmap;
	private Paint mPaint;
	private Canvas mCanvas;
	private int BitmapW;
	private int BitmapH;
	private float scale;
	private FightData mFightData;

	private float TEMP=20;
	private PlayerData mPlayer;
	private PointF PlayerMapPoint;
	private PointF PlayerScreenPoint;
	private PointF DirectionPoint;
	private Bitmap PlayerBitmap;
	private Canvas PlayerCanvas;
	private Paint mYellowPaint;
	private Rect mRect;
	private PointF ScreenInMap;
	private void debug()
	{


	}
	public FightMap()
	{
		BitmapW=150000;
		BitmapH=8000;
		//this.mFightData=fightdata;
		if (MainActivity.ifdebug)
		{
			debug();
		}

		PlayerMapPoint=new PointF(BitmapW/2,BitmapH/2);
		DirectionPoint=new PointF(0,0);
		PlayerBitmap=Bitmap.createBitmap(200,200,Bitmap.Config.ARGB_8888);
		PlayerCanvas=new Canvas(PlayerBitmap);
		mYellowPaint=new Paint();
		mYellowPaint.setColor(Color.YELLOW);
		mYellowPaint.setStyle(Paint.Style.FILL);
		PlayerCanvas.drawCircle(100,100,100,mYellowPaint);
		PlayerScreenPoint=new PointF(1250,800);
		mRect=new Rect();
		mRect.set(200,100,1800,750);
		ScreenInMap=new PointF(PlayerMapPoint.x-1250,PlayerMapPoint.y-800);


	}
	public void setDirectionPoint(float x,float y)
	{
		DirectionPoint.set(x,y);
	}
	private void init()
	{
		if (mBitmap == null)
			mBitmap = Bitmap.createBitmap(BitmapW, BitmapH, Bitmap.Config.ARGB_8888);
		mCanvas = new Canvas(mBitmap);
		if (mPaint == null)
		{
			mPaint = new Paint();
			mPaint.setStyle(Paint.Style.STROKE);
			mPaint.setColor(MainActivity.mSPM.getSmallMapColor());
		}

	}
	public void setSize(int Weight, int Hight)
	{
		this.BitmapW = Weight;
		this.BitmapH = Hight;

	}
	public void setScale(float Scale)
	{
		this.scale = Scale;
	}
	public FightMap(int Weight, int Hight, float Scale)
	{
		init();
		setSize(Weight, Hight);
		setScale(Scale);
	}
	public FightMap(int Weight, int Hight)
	{
		setScale(1);
		setSize(Weight, Hight);
	}
	private void render()
	{
		PointF T=new PointF(PlayerMapPoint.x,PlayerMapPoint.y);
		PlayerMapPoint.set(T.x-DirectionPoint.x,T.y-DirectionPoint.y);
		if(PlayerScreenPoint.x<=mRect.left||PlayerScreenPoint.y>mRect.right)
		{
			T.set(ScreenInMap.x,ScreenInMap.y);

		}

	}
	private void reDraw()
	{
		render();
		mCanvas.drawBitmap(PlayerBitmap,PlayerMapPoint.x,PlayerMapPoint.y,mPaint);


	}
	public Bitmap getmBitmap()
	{
		reDraw();
		return  mBitmap;
	}

}
